import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dell
 * Date: 2023-11-29
 * Time: 13:40
 */
class Money implements  Cloneable{
    int money=10;
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
class Student implements Cloneable{
    //标记接口
    String name;
    int age;
    Money money =new Money();

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", money=" + money +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Student tmp=new Student();
        tmp.money=(Money) this.money.clone();
        //return super.clone();
        return tmp;
    }

    @Override
    public boolean equals(Object obj) {
        //  Student student=(Student) obj;
        //

        return false;    // return age==student.age;
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, money);
    }
}
public class test2 {
    public static void main(String[] args)throws CloneNotSupportedException {
        Student student=new Student();
        student.money.money=19;//浅拷贝
        Student student1=(Student) student.clone();
        System.out.println(student1);
        System.out.println(student);
        System.out.println("===========================================");
        System.out.println(student.money.money);
        System.out.println(student1.money.money);
        System.out.println("===========================================");
        student.money.money=99;//深拷贝
        System.out.println(student.money.money);
        System.out.println(student1.money.money);
//        Class<?> c=student1.getClass();
//        System.out.println(c);
//        System.out.println(student==student1);
        System.out.println(student.equals(student1));

    }
}